﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy1_10
{
    public partial class Form1 : Form
    {
        
        private bool numMatch(string s)
        {
            Regex reg = new Regex("^[0-9]*$");
            if (reg.IsMatch(s)) return true;
            else return false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text != "")
                textBox3.Text = (float.Parse(textBox1.Text) / float.Parse(textBox2.Text)).ToString();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {

        }
private void button3_Click(object sender, EventArgs e)
        {

        }
private void button4_Click(object sender, EventArgs e)
        {
            if(textBox2.Text=="0")
            {
                MessageBox.Show("除数不得为零！");
                textBox2.Text = "";
                textBox2.Focus();
                return;
            }
            if (textBox1.Text != "" && textBox2.Text != "")
                textBox3.Text = (float.Parse(textBox1.Text) / float.Parse(textBox2.Text)).ToString();
        }

private void button5_Click(object sender, EventArgs e)
        {

        }
private void button6_Click(object sender, EventArgs e)
        {

        }
private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if(!numMatch(textBox1.Text))
            {
                MessageBox.Show("只能是整数(>=0),请重试！");
                textBox1.Text = "";
                textBox1.Focus();
            }
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
